package com.atguigu.crowd.mvc.handler;
import com.atguigu.crowd.util.CrowdUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.atguigu.crowd.entity.Admin;
import com.atguigu.crowd.service.api.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class TestHandler {

    private Logger logger = LoggerFactory.getLogger(TestHandler.class);
    @Autowired
    private AdminService adminService;

    @RequestMapping("/test/ssm.html") //这里是访问路径 以下就是其controller
    public String testSSM(ModelMap modelMap, HttpServletRequest request){

        System.out.println("testSSM执行了。。。");

        List<Admin> adminList=adminService.getAll();

        modelMap.addAttribute("adminList",adminList);
        String a=null;
        System.out.println(a.length());

        return "target";
    }

    @ResponseBody
    @RequestMapping("/send/array.html")
    public String testReceiveArrayTwo(@RequestParam("array[]") List<Integer> array) {

        for (Integer number : array) {
            System.out.println("number="+number);
        }

        return "success";
    }

    @ResponseBody
    @RequestMapping("/send/array/three.html")
    public String testReceiveArrayThree(@RequestBody List<Integer> array) {

        for (Integer number : array) {
            logger.info("number="+number);
        }

        return "success";
    }



}
